﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace COFE.Web
{
    public static class COFEWSPath
    {
        public static string ToCOFEPath(string wsPath)
        {
            return wsPath.Replace("/", "\\");
        }

        public static string FromCOFEPath(string cofePath)
        {
            return cofePath.Replace("\\", "/");
        }

        public static string GetDirectoryName(string path)
        {
            if (String.IsNullOrEmpty(path))
                return null;

            if (path.EndsWith("/"))
                path = path.Substring(0, path.Length - 1); //Remove ending slash.

            int idx = path.LastIndexOf('/');
            if (idx == -1)
                return "";
            return path.Substring(0, idx);
        }

        public static string GetFileName(string path)
        {
            int idx = path.LastIndexOf('/');
            if (idx == -1)
                return path;
            return path.Substring(idx + 1);
        }
    }
}
